<style lang="scss" scope>
@import './orderDetails.css';
</style>

<template>
  <div class="orderDetails-wrapper">
    <TitleBar
      title="订单信息"
      refresh
    />
    <Panel>
      <table class="order-details">
        <tbody>
          <tr>
            <td><div>订单编号</div></td>
            <td><div>{{ orderTable.orderCode }}</div></td>
          </tr>
          <!-- <tr>
            <td><div>第三方支付订单编号</div></td>
            <td><div></div></td>
          </tr> -->
          <tr>
            <td><div>订单金额</div></td>
            <td><div>{{ "¥" + orderTable.totalPrice }}</div></td>
          </tr>
          <tr>
            <td><div>支付方式</div></td>
            <td><div>{{ payConvert(orderTable.payType) }}</div></td>
          </tr>
          <tr>
            <td><div>支付时间</div></td>
            <td><div>{{ orderTable.orderTime }}</div></td>
          </tr>
          <tr>
            <td><div>订单状态</div></td>
            <td><div>{{ orderStatusConvert(orderTable.orderState) }}</div></td>
          </tr>
        </tbody>
      </table>
    </Panel>
  </div>
</template>

<script>

import Panel from '@/components/Panel/Panel'
// import Banner from '@/components/Banner/Banner'
import { getOrderDetails } from '@/api/order'
export default {
  components: {
    Panel
  },
  data() {
    return {
      orderTable: {
        createTime: 1566044261000,
        id: 11,
        orderCode: 'S1003',
        orderDetail: null,
        orderSource: 'wx',
        orderState: 2,
        orderTime: 1566649074000,
        payLog: null,
        payTime: 1566476269000,
        payType: null,
        remarks: null,
        totalPrice: 300,
        updateTime: null,
        userCode: '8888'
      }
    }
  },
  created() {
    // this.orderTable = JSON.parse(window.sessionStorage.getItem('orderDetails'))
    this.getOrderDetails()
  },
  methods: {
    getOrderDetails() {
      const { orderCode } = this.$route.query
        getOrderDetails({ orderCode }).then(res => {
          if (res.code == 200) {
            this.orderTable = res.data
            this.orderTable.totalPrice = this.orderTable.totalPrice/100
          } else if (res == 500) {
            alert(res.message)
          }
        })
    },
    payConvert(i) {
      if (i === 'wx') {
        return '微信'
      } else if (i === 'zfb') {
        return '支付宝'
      } else if (i === 'cd') {
        return '银行卡'
      } else if (i === 'ye') {
        return '余额'
      } else if (i === 'jb') {
        return '金币'
      }
    },
    orderStatusConvert(i) {
      if (i === 1) {
        return '已下单待支付'
      } else if (i === 2) {
        return '已支付待发货'
      } else if (i === 3) {
        return '已发货'
      } else if (i === 4) {
        return '待签收'
      } else if (i === 5) {
        return '已完成'
      } else if (i === 6) {
        return '支付异常'
      } else if (i === 7) {
        return '用户取消关闭订单'
      } else if (i === 8) {
        return '支付超时关闭订单'
      } else if (i === 9) {
        return '后台手动关闭订单'
      }
    }
  }
}
</script>
